home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / ghostscr / ghostscr.zip / TRACEOP.PS < prev    next >
Text File  |  1993-08-03  |  3KB  |  66 lines

  1. %    Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % Trace individual operators or procedures.
  20. % <opref> is <opname> or <opname> <dict> (dict defaults to userdict).
  21. % <opref> traceop prints vmem usage before;
  22. % <opref> <numargs|preproc> prints arguments or runs proc before;
  23. % <opref> <numargs|preproc> <numresults|postproc>
  24. %    also prints results or runs proc after.
  25. % If traceflush is true, flush the output after each printout.
  26. /traceflush true def
  27.  
  28. % Define the default "before" action
  29. /tracebefore { vmstatus 3 traceprint pop pop pop } def
  30.  
  31. % Define the default "after" action
  32. /traceafter { } def
  33.  
  34. /traceprint
  35.  { dup type /integertype eq
  36.     { 1 sub -1 0 { ( ) print index ==only } for }
  37.     { exec }
  38.    ifelse
  39.  } bind def
  40. /traceend
  41.  { traceflush { flush } if
  42.  } bind def
  43. /traceop
  44.  { userdict begin
  45.    dup type dup /nametype eq exch /dicttype eq or { { tracebefore } } if
  46.    1 index type dup /nametype eq exch /dicttype eq or { { traceafter } } if
  47.    /.tpost exch def /.tpre exch def
  48.    dup type /dicttype ne
  49.     { dup where not { userdict 1 index {} put userdict } if
  50.     } if
  51.    /.tdict exch def /.tname exch def
  52.    .tdict dup systemdict eq { pop userdict } if /.tddict exch def
  53.    [ .tname /=only cvx ( ) /print cvx
  54.      /.tpre load /traceprint cvx /traceend cvx
  55.      .tdict .tname get
  56.      dup xcheck
  57.       { dup type dup /arraytype eq exch /packedarraytype eq or
  58.          { /exec cvx
  59.      } if
  60.       } if
  61.      /.tpost load /traceprint cvx (\n) /print cvx /traceend cvx
  62.    ] cvx .tddict exch .tname exch put end
  63.  } bind def
  64. /tracebind /bind load def    % in case someone wants to put it back
  65. /bind { } def        % disable
  66.